<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>金保联档案管理系统</title>
<jsp:include page="../inc/easyui.jsp"></jsp:include>
<link rel="icon" href="../image/toplogo.png" type="image/x-icon"/>
<link rel="shortcut icon" href="../image/toplogo.png" />
</head>
<script type="text/javascript" charset="utf-8">
var xmXgId=<%=request.getParameter("xmXgId")%>;
var admin_dagl_da_datagrid;
var admin_dagl_da_searchForm = undefined;
$(function(){
	admin_dagl_da_searchForm = $('#admin_dagl_da_searchForm').form();
	  $("#admin_dagl_da_searchButton").bind('click', function(){   
		  
		  admin_dagl_da_search(); 
	    }); 
	  $("#admin_dagl_da_CleanSearchButton").bind('click', function(){   
		  
		  admin_dagl_da_cleanSearch();
    }); 
		
	  admin_dagl_da_datagrid=$('#admin_dagl_da_datagrid').datagrid({
		url : '${pageContext.request.contextPath}/daAction!dataGrid.action?xgId='+xmXgId,
		title:'指定箱柜档案信息查询',
		iconCls:'icon-search',
		toolbar : '#admin_dagl_da_toolbar',
		fit : true,
		border : false,
		striped:true,
		idField : 'id',
		rownumbers: true,		//显示行号
		fitColumns : true,		//显示横向滚动条
		pagination : true,
		pageSize : 30,
		pageList : [ 10,20, 30, 40, 50 ],
		sortName:'cjsj',
		sortOrder:'desc',
		columns : [[{
					title:'编号',
					width:100,
					checkbox:true,
				},{
					title:'编号',
					field:'id',
					width:100,
					align : 'center',
					sortable:true,
					editor:{
						type:'text'
					}
				},{
					title : '箱柜编号',
					field : 'xgId',
					width : 80,
					align : 'center',
					sortable:true,

					editor:{
						type:'combobox',
						options:{
							required:true,
							valueField:'id',
							textField:'id',
							url:'${pageContext.request.contextPath}/xgAction!comboboxInfo.action',
							editable:true,
							missingMessage:'箱柜编号必填'
							
						}
					}
			
				},{
					title : '状态',
					field : 'ztList',
					width : 80,
					align : 'center',
					sortable:true,
					formatter:function(value){
						if(value){
							return value[0];
						}
					},
					editor:{
						type:'comboboxFk',
						options:{
							required:true,
							valueField:'id',
							textField:'zt',
							url:'${pageContext.request.contextPath}/ztAction!comboboxInfo.action',
							editable:false,
							missingMessage:'状态必填'
							
						}
					},
					styler:function(value,row,index){  
                         if (value[1] == '1'){  
                             return 'background-color:#ffee22;color:blue;';  
                         }else if(value[1] == '3'){
                         	return 'background-color:#ffee22;color:red;';  
                         }else if(value[1] == '2'){
                         	return 'background-color:#ffee22;color:green;';  
                         }else if(value[1] == '4'){
                         	return 'background-color:#ffee22;color:gray;';  
                         }
                   }  
			
				},{
					title : '公司',
					field : 'gsmc',
					width : 80,
					align : 'center',
					sortable:true,
					editor:{
						type:'combobox',
						options:{
							valueField:'gs',
							textField:'gs',
							url:'${pageContext.request.contextPath}/gsAction!comboboxInfo.action',
							editable:false,
							
						}
					}
			
				},{
					title : '类别',
					field : 'lbmc',
					width : 80,
					align : 'center',
					sortable:true,
					editor:{
						type:'combobox',
						options:{
							valueField:'lb',
							textField:'lb',
							url:'${pageContext.request.contextPath}/lbAction!comboboxInfo.action',
							editable:false,
							
						}
					}
			
				},{
					title : '档案夹编号',
					field : 'ided',
					width : 80,
					align : 'center',
					sortable:true,

					editor:{
						type:'combobox',
						options:{
							valueField:'id',
							textField:'id',
							url:'${pageContext.request.contextPath}/daAction!comboboxInfo.action',
							editable:true,							
						}
					}
			
				},{
					title : '备注',
					field : 'bz',
					width : 130,
					align : 'center',
					sortable:true,
					editor:{
						type:'text'
					}
			
				},{
					title:'创建时间',
					field:'cjsj',
					width:100,
					sortable:true,
					editor:{
						type:'datetimebox',
						options:{
							editable:false,
						}
					}
				}]],
				onLoadError:function(){
					$.messager.alert('提示', '请登录！', 'error');
				}
			
			});
			
		});
function admin_dagl_da_search() {
		admin_dagl_da_datagrid.datagrid('load', serializeObject(admin_dagl_da_searchForm));
}
function admin_dagl_da_cleanSearch() {
	admin_dagl_da_datagrid.datagrid('load', {});
	admin_dagl_da_searchForm.find('input').val('');
}
function admin_dagl_da_gl(ztId) {
			var rows = admin_dagl_da_datagrid.datagrid('getSelections');
			if (rows.length > 0) {
				$('#admin_dagl_da_dialog').show();
					$('#admin_dagl_da_dialog').dialog({
						collapsible: true,
						modal:true,
						buttons:[{
						text: '确认申请',
						iconCls: 'icon-ok',
						handler: function() { 
							var ids = [];
							$.messager.confirm('请确认', '您要操作当前所选项目？', function(r) {
								if (r) {
									for ( var i = 0; i < rows.length; i++) {
										ids.push(rows[i].id);
									}
									$.ajax({
										url : '${pageContext.request.contextPath}/daLogAction!add.action',
										data : {
											ids : ids.join(','), ztId:ztId,bz:$('#bz').val()
										},
										type:'POST',
										dataType : 'json',
										success : function(r) {
											if (r.success) {
												admin_dagl_da_datagrid.datagrid('unselectAll');
												$.messager.show({
													msg : r.msg,
													title : '成功'
												});
												$('#admin_dagl_da_dialog').dialog('close');
												admin_dagl_da_datagrid.datagrid('load');
												$('#bz').val('');
											} else {
												admin_dagl_da_datagrid.datagrid('load');
												$.messager.alert('错误', r.msg, 'error');
											}
										}
									});
								}
							});
						}},{
						text: '取消申请',
						iconCls: 'icon-no',
						handler: function() { 
							$('#admin_dagl_da_dialog').dialog('close');
							admin_dagl_da_datagrid.datagrid('unselectAll');
						}
						}
						]
				});
			} else {
				$.messager.alert('提示', '请选择要操作的记录！', 'error');
			}
		}
</script>
<body>
<div class="easyui-layout" fit="true">
	<div region="center" border="false" style="overflow: hidden;">
		<div id="admin_dagl_da_toolbar" class="datagrid-toolbar" style="height: auto;display: none;">
			<fieldset>
				<legend>筛选</legend>
					<form id="admin_dagl_da_searchForm">
						<table class="admin_dagl_da_searchForm datagrid-toolbar" style="width: 100%;height: 100%;">
						<tr>
						<td>
						<label>档案编号:&nbsp;</label><input name="id" id="id" />
						<label>档案状态:&nbsp;</label><input name="ztId" id="ztId" class='easyui-combobox' style="width:150px;" data-options="valueField:'id',textField:'zt',url:'${pageContext.request.contextPath}/ztAction!comboboxInfo.action',editable:false" />
						<label>创建时间:&nbsp;</label><input name="startCjsj" id="startCjsj" editable="fasle" class="easyui-datetimebox"/>&nbsp;至&nbsp;<input name="endCjsj" id="endCjsj" editable="fasle" class="easyui-datetimebox"/>
						<a href='javascript:void(0);' id="admin_dagl_da_searchButton" class='easyui-linkbutton' data-options="iconCls:'icon-search'">查询</a>
						<a href='javascript:void(0);' id="admin_dagl_da_CleanSearchButton" class='easyui-linkbutton' data-options="iconCls:'icon-cancel'">清空</a>
						</td>
						</tr>
						</table>
					</form>
			</fieldset>
			<div>
				<a class="easyui-linkbutton" iconCls="icon-sqdy" onclick="admin_dagl_da_gl(1);" plain="true" href="javascript:void(0);">申请调阅</a>
				<a class="easyui-linkbutton" iconCls="icon-sqrk" onclick="admin_dagl_da_gl(2);" plain="true" href="javascript:void(0);">申请入库</a>
				<a class="easyui-linkbutton" iconCls="icon-sqsc" onclick="admin_dagl_da_gl(3);" plain="true" href="javascript:void(0);">申请删除</a>
				<a class="easyui-linkbutton" iconCls="icon-sqxh" onclick="admin_dagl_da_gl(4);" plain="true" href="javascript:void(0);">申请销毁</a>
				<a class="easyui-linkbutton" iconCls="icon-undo" onclick="admin_dagl_da_datagrid.datagrid('unselectAll');" plain="true" href="javascript:void(0);">取消选中</a>
			</div>
		</div>
		<table id="admin_dagl_da_datagrid"></table>
	</div>
</div> 

<div id="admin_dagl_da_dialog"  style="width:450px; height: 280px; display:none;" title="申请信息" iconCls="icon-tip">
		
		<table title="*您可以添加上自己的申请备注信息!" style="width: 100%;height: 100%;">
		<tr>
		<td>申请说明:</td><td><textarea rows="4" name="bz" id="bz" cols="30"></textarea></td>
		</tr>
		</table>
</div> 
</body>
</html>